package com.bensonbasement.snorflux.server.world.prototypes;

import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;

import com.bensonbasement.snorflux.server.ContentRepository;
import com.bensonbasement.snorflux.server.verbs.Verb;


public class WorldElementPrototype /*extends FlexPyObject*/ implements Serializable {
	
	public static final WorldElementPrototype WORLDELEMENT;
	static {
		WORLDELEMENT = new WorldElementPrototype("core_worldelement");
		WORLDELEMENT.setName("Unnamed");
		WORLDELEMENT.setGlyph("NOGLYPH");
	}
	
	private WorldElementPrototype parent;
	
	private final String prototypeID;
	private String name = null;
	private String glyph = null;
	
	public WorldElementPrototype(String prototypeID, WorldElementPrototype parent) {
		this(prototypeID);
		this.parent = parent;
	}
	
	private WorldElementPrototype(String prototypeID) {
		this.parent = null;
		this.prototypeID = prototypeID;
		ContentRepository.getInstance().addPrototype(this);
	}
	
//	@Override
//	public PyObject __findattr_ex__(String name) {
//		PyObject retVal;
//		try {
//			retVal = super.__findattr_ex__(name);
//		}
//		catch (PyException ex) {
//			if (ex.type == Py.AttributeError || ex.type == Py.TypeError) {
//				retVal = null;
//			}
//			else {
//				throw ex;
//			}
//		}
//		if (retVal == null && this.parent != null) {
//			retVal = this.parent.__findattr__(name);
//		}
//		return retVal;
//	}

	public String findName() {
		if (this.name != null) {
			return this.name;
		}
		else {
			return this.parent.findName();
		}
	}

	public void setName(String name) {
		this.name = name;
	}

	public String findGlyph() {
		if (this.glyph != null) {
			return this.glyph;
		}
		else {
			return this.parent.findGlyph();
		}
	}

	public void setGlyph(String glyph) {
		this.glyph = glyph;
	}

	public String getName() {
		return name;
	}

	public String getGlyph() {
		return glyph;
	}

	protected WorldElementPrototype getParent() {
		return parent;
	}
	
	public String getPrototypeID() {
		return prototypeID;
	}
}
